class X{
    public void draw(){
        System.out.println("x");
    }
}
class Y extends X{
    @Override
    public void draw() {
        System.out.println("y");
    }
}
public class Z extends X{
    @Override
    public void draw() {
        System.out.println("z");
    }

    public static void main(String[] args) {
        X x = new X();
        X y = new Y();
        X z = new Z();

        X[] w = {x,y,z};
        for (X w1 : w) {
            w1.draw();
        }
    }
}
